package com.yc.damai.util;

import com.yc.damai.biz.BizException;

import java.util.Collection;
import java.util.Collections;
import java.util.Map;

/**
 * @author navy
 * @company 源辰信息
 * @date 2024/9/23
 * @email haijunzhou@hnit.edu.cn
 */
public class Utils {

    public static void check(boolean bool, String msg) throws BizException {
        if(bool) throw new BizException(msg, 0);
    }

    public static void isEmpty(Object object, String msg) throws BizException {
        check(object == null, msg);
        if(object instanceof String){
            String s = (String) object;
            check(s.isBlank(), msg);
        } else if(object instanceof Collection){
            Collection c = (Collection) object;
            check(c.isEmpty(), msg);
        } else if(object instanceof Map){
            Map m = (Map) object;
            check(m.isEmpty(), msg);
        }
    }
}
